/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2024-07-23 13:25:44
 * @LastEditors: 赵大壮
 */
import dzMsgBox from "@/utils/DZMessageBox";
import { Component, Vue, Inject } from "vue-property-decorator";
import UiDialogAddStoreBanner from "@/components/ui-dialog/UiDialogAddStoreBanner.vue"
import DZServiceBanner from "../../service/DZServiceBanner";
import DZModelBanner from "../../model/DZModelBanner";
import DZModelStoreBanner from "../../model/DZModelStoreBanner";

@Component({
    components: { UiDialogAddStoreBanner }
})
export default class Index extends Vue {

    s_banner = new DZServiceBanner();

    dialog_add_banner = false;

    created() {
        this.action_list_banner();
    }

    mounted() {

    }

    beforeDestroy() {

    }

    action_list_banner() {
        this.s_banner.net_list_store_banner();
    }

    action_edit_banner(item: DZModelStoreBanner) {
        this.s_banner.m_store_banner = JSON.parse(JSON.stringify(item))
        this.dialog_add_banner = true;
    }

    action_do_edit(item: DZModelStoreBanner) {
        var that = this;
        this.s_banner.m_store_banner = JSON.parse(JSON.stringify(item))
        if (this.s_banner.m_store_banner.id) {
            this.s_banner.net_edit_store_banner(() => {
                that.action_list_banner();
            });
        } else {
            this.s_banner.net_add_store_banner(() => {
                that.action_list_banner();
            });
        }
    }

    action_del_banner(id) {
        this.s_banner.m_store_banner.id = id;
        dzMsgBox.del("是否删除此Banner", () => {
            this.s_banner.net_del_store_banner(() => {
                this.action_list_banner();
            });
        })
    }

    action_page_change(current) {
        this.s_banner.m_page.page = current;
        this.action_list_banner();
    }

    /** 保存排序 */
    action_sort_save (row) {
        this.s_banner.net_edit_store_sort(row.id,row.sort,() => {
            this.action_list_banner();
        });
    }

    
    action_move_up(row) {
        this.s_banner.net_store_move_up(row.id, () => {
            this.action_list_banner();
        });
    }

    action_move_down(row) {
        this.s_banner.net_store_move_down(row.id, () => {
            this.action_list_banner();
        });
    }

    action_move_top(row) {
        this.s_banner.net_store_move_top(row.id, () => {
            this.action_list_banner();
        });
    }

    action_cancel_top(row) {
        this.s_banner.net_store_cancel_top(row.id, () => {
            this.action_list_banner();
        });
    }
}